package com.example.demo.testdemo;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

public class SqlProducer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("producer_tag_group");
        producer.setNamesrvAddr("127.0.0.1:9876");
        producer.start();
        for (int i = 0; i < 10; i++) {
            //消费者只能消费 TagTopic主题下的 TAG1
            Message message = new Message("SqlTopic","TAG1",("hello"+i).getBytes());
            //给消息绑定属性
            message.putUserProperty("i",String.valueOf(i));
            producer.send(message);
        }
        producer.shutdown();
    }
}
